<template>
	<view class="minebox">

		<view v-if="pageFlag=='member'" class="studentmine">
			<view class="title">
				<!-- <u-icon name="arrow-left" size="24"></u-icon> -->
				<text style="margin-left: 24rpx;">我的</text>
			</view>
			<view class="minebox">
				<view class="userinfo" @click="gotopagestudent('gerenxinxi')">
					<view class="avatarbox">
						<image class="avatarimg" :src="message.photos.url"></image>
					</view>
					<view class="nameandsex">
						<view class="username">
							{{message.name == undefined ? "" : message.name}}
						</view>
						<view class="">
							<image v-if="message.gender =='男'" class="seximg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/nan.png"></image>
							<image v-else class="seximg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/nv.png">
							</image>
						</view>
					</view>
					<view class="zhuanye">
						{{message.school == undefined ? "" : message.school }}/{{message.speciality == undefined ? "" : message.speciality}}
					</view>
				</view>

				<view class="gotoList">
					<view class="gotoListbox" @click="gotopagestudent('gerenxinxi')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/grxx.png"></image>
							<view class="gotoListboxlefttext">
								个人信息
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopagestudent('myteacher')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/wdls.png"></image>
							<view class="gotoListboxlefttext">
								我的老师
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopagestudent('guanyupingtai')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/gypt.png"></image>
							<view class="gotoListboxlefttext">
								关于平台
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopagestudent('yijianfankui')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/yjfk.png"></image>
							<view class="gotoListboxlefttext">
								意见反馈
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopagestudent('lianxiwomen')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/lxwm.png"></image>
							<view class="gotoListboxlefttext">
								联系我们
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
				</view>
				<view class="exitbtn" @click="openpopstudent">
					退出登录
				</view>
			</view>

		</view>

		<view v-if="pageFlag=='teacher'" class="teachermine">
			<view class="title">
				<u-icon name="arrow-left" size="24" @click="back"></u-icon>
				<text style="margin-left: 24rpx;">个人中心</text>
			</view>

			<view class="minebox">
				<view class="imgandmessage" @click="gotopage('gerenxinxi','1')">
					<view class="imgbox">
						<image class="handleimg" :src="mineData.photos.url"></image>
					</view>
					<view class="message">
						<view class="nameandmessage">
							<view class="name" style="width: 170rpx; ">
								{{mineData.name  == undefined ? "" : mineData.name}}
							</view>
							<view class="jibie">
								{{mineData.school == undefined ? "" : mineData.school}}/{{mineData.category_text == undefined ? "" : mineData.category_text}}
							</view>
						</view>
						<view class="desc">
							{{mineData.brief_introduction  == undefined ? "" : mineData.brief_introduction}}
						</view>
						<view class="zhuanye">
							<view class="zhuanyeitem" v-for="(item,index) in mineData.science_ids_text">
								{{item}}
							</view>
						</view>

					</view>
				</view>

				<view class="gotoList">
					<view class="gotoListbox" @click="gotopage('gerenxinxi','1')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/grxx.png"></image>
							<view class="gotoListboxlefttext">
								个人信息
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopage('mystudent')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/wdls.png"></image>
							<view class="gotoListboxlefttext">
								我的学生
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopage('guanyupingtai')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/gypt.png"></image>
							<view class="gotoListboxlefttext">
								关于平台
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopage('yijianfankui')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/yjfk.png"></image>
							<view class="gotoListboxlefttext">
								意见反馈
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="gotoListbox" @click="gotopage('lianxiwomen')">
						<view class="gotoListboxleft">
							<image class="gotoListboxleftimg"
								src="http://sssx.nanjingyunpeng.cn/uploads/tupian/image/lxwm.png"></image>
							<view class="gotoListboxlefttext">
								联系我们
							</view>
						</view>
						<view class="gotoListboxright">
							<u-icon size="20" name="arrow-right"></u-icon>
						</view>
					</view>
				</view>
				<view class="" style="height: 40rpx;">

				</view>
				<view class="exitbtn" @click="openpop">
					退出登录
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	import {
		getpersonal,
		usermessage,
		teacherCurrent
	} from "@/api/api.js"
	const app = getApp()
	export default {

		data() {
			return {
				value1: 1,
				show: false,
				userInfo: {},
				message: {},
				// show: false,
				mineData: {}, //我的信息
				pageFlag: ''
			}

		},
		onLoad() {
			this.getpersonals()
			this.getmessage()
			this.getMineDatas()
			this.getusermessage()
		},
		onShow() {
			this.getpersonals()
			this.getmessage()
			this.getMineDatas()
			this.getusermessage()
		},
		methods: {
			async getusermessage() {
				let res = await usermessage()
				console.log("当前用户信息", res)
				this.pageFlag = res.data.identity
			},
			async getpersonals() {
				let res = await usermessage()
				if (res.code == 1) {
					console.log("用户信息", res)
					this.userInfo = res.data
				}
			},
			async getmessage() {
				let res = await getpersonal()
				if (res.code == 1) {
					console.log("学历信息", res)
					this.message = res.data
				}
			},
			// click1(e) {
			// 	uni.redirectTo({
			// 		url: "/pages_students/home/index"
			// 	})
			// },
			gotopagestudent(pageName) {
				if (pageName == "lianxiwomen") {
					uni.navigateTo({
						url: "/pages_students/lianxiWomen/index"
					})
				}
				if (pageName == "guanyupingtai") {
					uni.navigateTo({
						url: "/pages_students/guanyuPingtai/index"
					})
				}
				if (pageName == "yijianfankui") {
					console.log("yijianfankui")
					uni.navigateTo({
						url: "/pages_students/backkui/index"
					})
				}
				if (pageName == "myteacher") {
					console.log("wodelaoshi")
					uni.navigateTo({
						url: "/pages_students/myTeacher/index"
					})
				}
				if (pageName == "gerenxinxi") {
					uni.navigateTo({
						// url: "/pages_students/perfect/index"
						url: `/pages_students/perfect/index?type=${1}`
					})
				}
			},
			openpopstudent() {
				let that = this
				uni.showModal({
					// title: '提示',
					content: '确定要退出登录吗？',
					confirmColor: '#4A9CFF',
					success: async function(res) {
						console.log("是否选择", res)
						if (res.confirm) {
							that.subok()
						}
					}
				})
				// this.show = true
			},
			// close() {
			// 	this.show = false
			// },
			subok() {
				uni.removeStorageSync("token")
				uni.removeStorageSync("userInfo")
				this.show = false
				uni.redirectTo({
					url: "/pages/index/index"
				})
				uni.showToast({
					title: '已退出',
					icon: 'none',
					duration: 500
				})

			},
			async getMineDatas() {
				let res = await teacherCurrent()
				if (res.code == 1) {
					console.log("当前导师信息", res)
					this.mineData = res.data
					this.mineData.science_ids_text = this.mineData.science_ids_text.split(",")
					console.log("专业", this.mineData.science_ids_text)
				}
			},
			back() {
				uni.navigateTo({
					url: "../home/index"
				})
			},
			gotopage(pageName, show) {
				if (pageName == "lianxiwomen") {
					uni.navigateTo({
						url: "/pages_teachers/lianxiWomen/index"
					})
				}
				if (pageName == "guanyupingtai") {
					uni.navigateTo({
						url: "/pages_teachers/guanyuPingtai/index"
					})
				}
				if (pageName == "yijianfankui") {
					console.log("yijianfankui")
					uni.navigateTo({
						url: "/pages_teachers/backkui/index"
					})
				}
				if (pageName == "mystudent") {
					uni.navigateTo({
						url: "/pages_teachers/mystudent/index"
					})
				}
				if (pageName == "gerenxinxi") {
					uni.navigateTo({
						url: `/pages_teachers/perfect/index?show=${show}`
					})
				}
			},

			openpop() {
				// this.show = true
				let that = this
				uni.showModal({
					// title: '提示',
					content: '确定要退出登录吗？',
					confirmColor: '#4A9CFF',
					success: async function(res) {
						console.log("是否选择", res)
						if (res.confirm) {
							that.subok()
						}
					}
				})
			},
			// close() {
			// 	this.show = false
			// },
			subok() {
				uni.removeStorageSync("token")
				uni.removeStorageSync("userInfo")
				this.show = false
				uni.redirectTo({
					url: "/pages/index/index"
				})
				uni.showToast({
					title: '已退出',
					icon: 'none',
					duration: 500
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	page {
		height: 100%;
		background-color: #F7F8FA;
	}

	.minebox {


		.studentmine {
			min-height: 100%;
			background-color: #F7F8FA;

			.popcontent {
				width: 610rpx;
				height: 196rpx;
				background: #FFFFFF;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				opacity: 1;
				padding-top: 50rpx;
				box-sizing: border-box;
				z-index: 99;

				.text {
					width: 100%;
					text-align: center;
					font-size: 30rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
					line-height: 45rpx;
					padding: 0 40rpx;
					display: inline-block;
				}

				.btnbox {
					width: 100%;
					height: 100rpx;
					border-top: 1px solid gainsboro;
					box-sizing: border-box;
					margin-top: 70rpx;
					display: flex;

					.btn {
						width: 50%;
						text-align: center;
						line-height: 100rpx;
						font-size: 32rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 38rpx;
						padding-top: 30rpx;
						box-sizing: border-box;
					}

					.btnok {
						border-left: 1px solid gainsboro;
						color: #4A9CFF;
					}
				}

			}

			.title {
				width: 100%;
				height: 176rpx;
				padding-top: 110rpx;
				box-sizing: border-box;
				background-color: #FFFFFF;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #333333;
				line-height: 38rpx;
				padding-left: 34rpx;
				box-sizing: border-box;
			}

			.minebox {
				width: 690rpx;
				height: 1156rpx;
				background: #FFFFFF;
				border-radius: 30rpx 30rpx 30rpx 30rpx;
				opacity: 1;
				margin: 30rpx auto;

				.userinfo {
					width: 100%;
					height: 328rpx;
					// background-color: pink;
					padding-top: 60rpx;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
					align-items: center;

					.avatarbox {
						width: 140rpx;
						height: 140rpx;

						.avatarimg {
							width: 100%;
							height: 100%;
							border-radius: 70rpx;
						}
					}

					.nameandsex {
						display: flex;
						margin: 10rpx 0;

						.username {
							font-size: 32rpx;
							font-family: PingFang SC-Bold, PingFang SC;
							font-weight: bold;
							color: #333333;
							line-height: 38rpx;
						}

						.seximg {
							width: 36rpx;
							height: 36rpx;
							margin-left: 10rpx;
						}
					}

					.zhuanye {
						font-size: 32rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						line-height: 38rpx;
						width: 500rpx;
						text-align: center;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;

					}
				}

				.gotoList {
					width: 100%;
					height: 600rpx;
					margin-top: 30rpx;

					.gotoListbox {
						display: flex;
						align-items: center;
						justify-content: space-between;
						align-items: center;
						padding: 30rpx;
						box-sizing: border-box;
						width: 100%;

						.gotoListboxleft {
							display: flex;
							align-items: center;

							.gotoListboxleftimg {
								width: 48rpx;
								height: 48rpx;
							}

							.gotoListboxlefttext {
								font-size: 32rpx;
								font-family: PingFang SC-Regular, PingFang SC;
								font-weight: 400;
								color: #333333;
								margin-left: 20rpx;
							}
						}
					}
				}

				.exitbtn {
					width: 622rpx;
					height: 88rpx;
					background: #4A9CFF;
					border-radius: 40rpx 40rpx 40rpx 40rpx;
					font-size: 32rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					line-height: 38rpx;
					text-align: center;
					line-height: 88rpx;
					margin: 30rpx auto;
				}

			}

		}



		.teachermine {
			min-height: 100%;
			background: #F7F8FA;

			.popcontent {
				width: 610rpx;
				height: 196rpx;
				background: #FFFFFF;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				opacity: 1;
				padding-top: 50rpx;
				box-sizing: border-box;
				z-index: 99;

				.text {
					width: 100%;
					text-align: center;
					font-size: 30rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
					line-height: 45rpx;
					padding: 0 40rpx;
					display: inline-block;
				}

				.btnbox {
					width: 100%;
					height: 100rpx;
					border-top: 1px solid gainsboro;
					box-sizing: border-box;
					margin-top: 70rpx;
					display: flex;

					.btn {
						width: 50%;
						text-align: center;
						line-height: 100rpx;
						font-size: 32rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 38rpx;
						padding-top: 30rpx;
						box-sizing: border-box;
					}

					.btnok {
						border-left: 1px solid gainsboro;
						color: #4A9CFF;
					}
				}

			}

			.title {
				width: 100%;
				height: 176rpx;
				padding-top: 110rpx;
				box-sizing: border-box;
				background: #ffffff;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #333333;
				line-height: 38rpx;
				padding-left: 34rpx;
				box-sizing: border-box;

			}

			.minebox {
				width: 690rpx;
				box-sizing: border-box;
				background-color: #ffffff;
				margin: 30rpx auto;
				border-radius: 30rpx 30rpx 30rpx 30rpx;
				padding: 30rpx;

				.imgandmessage {
					width: 100%;
					margin-top: 20rpx;
					display: flex;
					justify-content: space-between;
					box-sizing: border-box;

					.imgbox {
						.handleimg {
							width: 200rpx;
							height: 240rpx;
							border-radius: 20rpx;
						}
					}

					.message {
						height: 240rpx;
						margin-left: 20rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.nameandmessage {
							width: 100%;
							display: flex;
							justify-content: space-between;
							align-items: center;
						}

						.desc {
							font-size: 26rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							color: #999999;
							line-height: 30rpx;
							text-overflow: -o-ellipsis-lastline;
							overflow: hidden; //溢出内容隐藏
							text-overflow: ellipsis; //文本溢出部分用省略号表示
							display: -webkit-box; //特别显示模式
							-webkit-line-clamp: 2; //行数
							line-clamp: 2;
							-webkit-box-orient: vertical
						}

						.jibie {
							width: 250rpx;
							font-size: 26rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: 400;
							color: #666666;
							line-height: 30rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
						}

						.name {
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
						}

						.zhuanye {
							display: flex;
							// justify-content: space-between;

							.zhuanyeitem {
								height: 34rpx;
								font-size: 24rpx;
								font-family: PingFang SC-Regular, PingFang SC;
								font-weight: 400;
								background: #F0F7FF;
								color: #4A9CFF;
								line-height: 28rpx;
								font-size: 24rpx;
								font-family: PingFang SC-Regular, PingFang SC;
								font-weight: 400;
								line-height: 28rpx;
								padding: 0 7rpx;
								padding-top: 4rpx;
								margin-right: 10rpx;
							}
						}
					}

				}

				.gotoList {
					width: 100%;
					height: 600rpx;
					margin-top: 30rpx;

					.gotoListbox {
						display: flex;
						align-items: center;
						justify-content: space-between;
						align-items: center;
						padding: 30rpx;
						box-sizing: border-box;
						width: 100%;

						.gotoListboxleft {
							display: flex;
							align-items: center;

							.gotoListboxleftimg {
								width: 48rpx;
								height: 48rpx;
							}

							.gotoListboxlefttext {
								font-size: 32rpx;
								font-family: PingFang SC-Regular, PingFang SC;
								font-weight: 400;
								color: #333333;
								margin-left: 20rpx;
							}
						}
					}
				}

				.exitbtn {
					width: 622rpx;
					height: 88rpx;
					background: #4A9CFF;
					border-radius: 40rpx 40rpx 40rpx 40rpx;
					font-size: 32rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					line-height: 38rpx;
					text-align: center;
					line-height: 88rpx;
					margin: 30rpx auto;
				}

			}

		}

	}
</style>